// 模拟flowRight
// function compose(...args){
//   return function(val){
//     return args.reverse().reduce(function(acc,fn){
//       return fn(acc)
//     },val)
//   }
// }

// ES6+
const compose = (...args) => val => args.reverse().reduce((acc, fn) => fn(acc), val);

const reverse = ary => ary.reverse();

const first = ary => ary[0];

const toUpper = str => str.toUpperCase();

const last = compose(toUpper, first, reverse);

const list = ['a', 'b', 'c', 'd'];
console.log(last(list))